package com.education.admin.api.controller.system;

import com.education.common.base.BaseController;
import com.education.common.utils.Result;
import com.education.common.utils.ResultCode;
import com.education.service.system.SystemRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 角色管理处理层
 * @author Jason
 * @version 1.0.0
 * @date 2021-11-24 20:59
 */
@RestController
@RequestMapping("/system/role")
public class SystemRoleController extends BaseController {

    @Autowired
    private SystemRoleService systemRoleService;

    /**
     * 获取角色列表
     * @param params
     * @return
     */
    @GetMapping
    public Result queryList(@RequestParam Map params) {
        return systemRoleService.queryList(params);
    }

    /**
     * 添加或修改角色
     * @param roleMap 要添加或修改角色的数据
     * @return
     */
    @PostMapping
    public Result saveOrUpdate(@RequestBody Map roleMap) {
        return systemRoleService.saveOrUpdate(roleMap);
    }

    @DeleteMapping("/{id}")
    public Result deleteById(@PathVariable("id")Integer id) {
        return systemRoleService.deleteById(id);
    }

    /**
     * 批量删除
     * @param roleIds 要删除的角色id集合
     * @return
     */
    @DeleteMapping("batchDeleteByRoleIds")
    public Result batchDeleteByRoleIds(@RequestBody List<Integer> roleIds) {
        return systemRoleService.batchDeleteByRoleIds(roleIds);
    }
}
